<section id="comment-list">
    <h4 class="comment-title">
        <?php if ($blog->commentNum > 0): ?>
            已有 <strong class="comment-number"><?= $blog->commentNum ?></strong> 条评论
        <?php elseif ($blog->isComment < 1): ?>
            本文关闭了评论
        <?php else: ?>
            还没有评论
        <?php endif ?>
    </h4>
    <ul class="comment-list">
        <?php
        function children($children) {
            foreach ($children as $k => $c):
                ?>
                <li class="comment-item" id="comment-<?= $c->id ?>">
                    <img class="author-avatar" src="<?= $c->avatar ?>" alt="<?= $c->author ?>"/>
                    <p class="comment-meta">
                        <a class="author-name" href="#"><?= $c->author ?></a>
                        <span class="comment-time"><?= date('m.d H:i', $c->createTime) ?></span>
                        <?php if ($c->parentId == 0): ?>
                            <span class="comment-floor">#<?= ($k + 1) ?></span>
                        <?php endif ?>
                        <a class="comment-reply" href="#" rel="<?= $c->id ?>">回复</a>
                    </p>
                    <div class="comment-content"><?= $c->content ?></div>
                    <?php if ($c->children): ?>
                        <ul class="comment-children-list">
                            <?php children($c->children) ?>
                        </ul>
                    <?php endif ?>
                </li>
            <?php
            endforeach;
        }

        ?>
        <?php children($comments); ?>
    </ul>
    <?php if ($blog->isComment > 0): ?>
        <form action="" id="comment-form" class="form clear" method="post">
            <p id="comment-reply-message"><span></span><a class="comment-reply-cancel" href="#">取消回复</a></p>
            <div id="author-meta" class="left">
                <p class="item">
                    <label for="author-name">称呼</label>
                    <input type="text" class="input" id="author-name" name="author" required="required">
                </p>
                <p class="item">
                    <label for="author-email">联系邮箱</label>
                    <input type="email" id="author-email" class="input" name="email" required="required">
                </p>
                <p class="item">
                    <label for="author-url">个人站点</label>
                    <input type="url" id="author-url" name="url" class="input">
                </p>
            </div>
            <div id="author-content" class="left">
                <textarea name="content" id="comment-content" class="input" required="required"></textarea>
                <input type="submit" id="comment-submit" class="button" value="提交"/>
                <input type="hidden" name="parentId" value="0" id="comment-parent"/>
            </div>
        </form>
    <?php endif ?>
</section>